package com.personal.website.lottery.web.controller;

import com.personal.website.lottery.web.service.ArticleService;
import com.personal.website.lottery.web.service.DoubleColorBallService;
import com.personal.website.lottery.web.service.NoticeService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by Gavin on 2016/2/5.
 */
@Controller
public class IndexController {

    @Resource
    private ArticleService articleService;
    @Resource
    private DoubleColorBallService doubleColorBallService;
    @Resource
    private NoticeService noticeService;

    @RequestMapping({"/", "/index"})
    public String root(Model model) {
        model.addAttribute("articles", this.articleService.getArticles(30));
        model.addAttribute("latestBall", this.doubleColorBallService.getLastestBall());
        model.addAttribute("notices", this.noticeService.getNoticeList(3));
        return "index";
    }

}
